Skip to content

Probe container's IP and forwarded IP for urcap endpoint - #614

Closed
urfeex wants to merge 2 commits into
UniversalRobots:masterfrom
urfeex:start_ursim_probe_multiple
Closed

urfeex wants to merge 2 commits into
UniversalRobots:masterfrom
urfeex:start_ursim_probe_multiple

Conversation

@urfeex

@urfeex urfeex commented Nov 3, 2026

Copy link
Copy Markdown
Member

In some situations, we might want to probe for the container's IP, while in other setups we might want to probe the forwarded http port on the host. Before, the host forward was used as soon as it was specified. With this change both are probed and the one that answers with a 200 status code is picked for installing the urcap.

In some situations, we might want to probe for the container's IP, while
in other setups we might want to probe the forwarded http port on the host.
Before, the host forward was used as soon as it was specified. With this
change both are probed and the one that answers with a 200 status code
is picked for installing the urcap.
@codecov

codecov Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 76.66667% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 83.44%. Comparing base (d14edd7) to head (e144383).
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
scripts/start_ursim.sh 76.66% 7 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #614      +/-   ##
==========================================
- Coverage   83.86%   83.44%   -0.43%     
==========================================
  Files         127      127              
  Lines        8388     8408      +20     
  Branches     3829     3829              
==========================================
- Hits         7035     7016      -19     
- Misses        946      980      +34     
- Partials      407      412       +5     
Flag Coverage Δ
python_scripts 49.69% <ø> (ø)
start_ursim 91.82% <76.66%> (-1.22%) ⬇️
unit 61.60% <ø> (+0.05%) ⬆️
ur20-latest 81.06% <ø> (+0.03%) ⬆️
ur5-3.14.3 80.80% <ø> (+0.02%) ⬆️
ur5e-10.11.0 ?
ur5e-10.12.0 77.60% <ø> (-0.04%) ⬇️
ur5e-10.7.0 76.10% <ø> (-0.02%) ⬇️
ur5e-5.9.4 81.08% <ø> (+0.03%) ⬆️
ur7e-10.13.0 78.15% <ø> (-0.04%) ⬇️
ur7e-10.14.0 ?

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

On UrService timeout, startup exits without stopping the launched container, leaving URSim holding its name and ports and blocking retries even in foreground mode.

1 open issue
What changed in this PR

This PR makes URCap installation work across container-network and host-forwarded setups by selecting an UrService endpoint that responds with HTTP 200.

Changes:

  • Probe the container IP first, then the forwarded HTTP endpoint.
  • Add a configurable readiness timeout and propagate setup failure.
  • Update tests for container-IP preference, forwarded-endpoint fallback, and timeout behavior.
File Description
tests/​test_start_ursim.bats Tests endpoint selection and UrService timeout handling.
scripts/​start_ursim.sh Probes available endpoints, bounds readiness waiting, and exits on setup failure.

Review effort: Balanced

Comment thread scripts/start_ursim.sh Resolved
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

The readiness loop can exceed the configured deadline and install after it expires, while the endpoint test does not specifically verify that the installation POST uses the forwarded URL.

No open issues 🎉

2 previously missed issues

In code that hasn't changed since last review

Medium severity Enforce the deadline for each probe and skip expired retries

scripts/​start_ursim.sh:439

The deadline is checked only before a full round of probes, so URSIM_URSERVICE_TIMEOUT=1 can still wait roughly eleven seconds if both requests reach their five-second limit. A successful forwarded probe can also trigger installation after the deadline has expired. Check the remaining budget before each probe, cap its timeout to that budget, and skip the retry sleep once the deadline expires.

Low severity Assert the installation POST uses the forwarded URL

tests/​test_start_ursim.bats:1039

This assertion also matches the forwarded readiness probe, so the test still passes if the installation POST uses the unreachable container IP or is omitted entirely. Assert the forwarded URL on the POST entry specifically, so this test verifies that the selected endpoint is actually used to install the URCap.

1 resolved since last review

Review effort: Balanced

@urfeex urfeex changed the title Probe container's IP and forwarded IP for urcaps endpoint Probe container's IP and forwarded IP for urcap endpoint Nov 3, 2026
@urfeex
urfeex marked this pull request as ready for review November 3, 2026 20:07
@urfeex
urfeex requested a review from a team November 3, 2026 20:07
@urfeex urfeex added the enhancement New feature or request label Nov 3, 2026
@cursor

cursor Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

PR Summary

Low Risk
Changes are limited to the URSim startup script and its tests, improving Docker/CI connectivity without touching robot control or auth paths.

Overview
PolyScope X startup no longer assumes a published host port is the right way to reach UrService. post_setup_polyscopex builds a list of candidate bases (container IP first, plus the forwarded docker port endpoint when present), polls the UrService urcaps API on each until one returns 200, and uses that URL for the URCapX POST. Waiting is bounded by URSIM_URSERVICE_TIMEOUT (default 300s); on timeout the script prints what was tried and returns failure.

main now treats post-setup failure as fatal: in non-detached mode it stops the URSim container before exiting. Bats coverage adds cases for preferring the container IP, falling back to the forwarded endpoint, and timing out.

Reviewed by Cursor Bugbot for commit e144383. Bugbot is set up for automated code reviews on this repo. Configure here.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

Reviewed by Cursor Bugbot for commit e144383. Configure here.

Comment thread scripts/start_ursim.sh
http_host="$IP_ADDRESS"
# UrService is reachable on the container IP from another container on ursim_net
# (CI). A published host port is required on Docker Desktop, where that IP is
# not routed. Probe both, and install the URCap through whichever answers.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR title needs grammar fixes

Low Severity

The PR title is missing articles and uses urcap instead of URCap. A clearer wording is Probe the container IP and forwarded IP for the URCap endpoint.

Fix in Cursor Fix in Web

Triggered by team rule: PR title

Reviewed by Cursor Bugbot for commit e144383. Configure here.

@urfeex

urfeex commented Nov 4, 2026

Copy link
Copy Markdown
Member Author

As discussed offline, we close this PR as the use case might be too obscure vs. the new (mainly unused) code path added to maintain.

@urfeex urfeex closed this Nov 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants